<ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui" 
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:b="http://xmlns.jcp.org/jsf/composite/bunsysComponents"
      template="/WEB-INF/templates/template.xhtml" >
      <ui:param name="idForm" value="frm" />
      <ui:param name="controller" value="#{facturaController}" />
	  <ui:define name="contentBody">
	  	<p:panel id="pnlDatos" header="#{msg['lbl_factura_m']}">
	  		<p:fieldset legend="#{msg['lbl_busqueda']}">
	  			<h:panelGrid columns="4" id="pnlfilter">
	  				<p:outputLabel value="#{msg['lbl_numero_proforma']}:" for="numproforma"/>
	  				<p:inputText id="numproforma" value="#{facturaDataManager.numeroproforma}" />
	  				<p:message for="numproforma"/>
	  				<p:commandButton icon="ui-icon-search" value="#{msg['btn_buscar']}" action="#{facturaController.buscarProforma}"
		  			 update="pnldetalle, detalleFactura, pnldatoscab, pnlDetallefactura :frm:sinimpuestos :frm:subtotal12  :frm:noiva :frm:exiva :frm:descuento :frm:iva12 :frm:total :frm:pnlformapago :frm:btngrabarsinfirma  :frm:btngrabarfirmeniviar :frm:btnfirmarenviar :frm:btncancelar"
		  			  process="@this :frm:pnlfilter"/>
			
	  			</h:panelGrid>
			</p:fieldset>
			<p:fieldset id="pnldatoscab" legend="#{msg['lbl_cabecera']}">
							<h:panelGroup layout="block">
							<p:panelGrid columns="1" style="width: 100%;">
								<f:facet name="header">
									<h:outputText value="#{msg['lbl_datos_generales']}"/>
								</f:facet>
								<h:panelGroup layout="block">
										<h:panelGrid columns="5" style="border: collapse;" >
											<p:outputLabel value="#{msg.lbl_numero_factura}:" for="numeroproforma" style="display:block;width:175px;"/>
											<p:inputText value="#{facturaDataManager.tadmcompania.codigoestablecimiento}" style="width: 50px;" disabled="true"/>
											<p:inputText value="#{facturaDataManager.tadmcompania.codigopuntoemision}" style="width: 50px;" disabled="true"/>
											<p:inputText id="numeroproforma"  value="#{facturaDataManager.tfaccabfactura.pk.numerofactura}" style="display:block;width:180px;" required="true" disabled="true">
												<pe:keyFilter mask="pint"/>
											</p:inputText>
											<p:message for="numeroproforma" display="icon"/>
										</h:panelGrid>
										<h:panelGrid columns="6" style="border: collapse;">
											
											<p:outputLabel value="#{msg.lbl_distrito_vuelo}:" for="distritovuelo" style="display:block;width:140px;"/>
											<p:selectOneMenu id="distritovuelo" value="#{facturaDataManager.tfaccabfactura.distritovuelo}" disabled="#{facturaDataManager.editable}"
												  var="p" style="width:180px" panelStyle="width:180px" required="true">						
												<f:selectItem itemLabel="Seleccione" itemValue="" />
												<f:selectItems value="#{facturaDataManager.catalogodistritovuelo}" var="item" itemValue="#{item.pk.codigocatalogo}" itemLabel="#{item.descripcion}" />
												<p:ajax update="codaerolinea" event="change" listener="#{facturaController.seleccionarAerolinea()}"
		                    					process="@this"/>
											</p:selectOneMenu>
											<p:message for="distritovuelo" display="icon"/>
											
											<p:outputLabel value="#{msg.lbl_dae}:" for="referendum" style="display:block;width:130px;"/>
											<h:panelGrid columns="2">
												<p:inputText id="codaerolinea" value="#{facturaDataManager.tfaccabfactura.aditionalProperties['codaerolinea']}" style="width: 50px;" disabled="true"/>
												<p:inputMask id="referendum" value="#{facturaDataManager.tfaccabfactura.referendo}" disabled="#{facturaDataManager.editable}"
												 style="display:block;width:180px;" required="true" mask="9999-99-99999999" />
											</h:panelGrid>
											<p:message for="referendum" display="icon"/>
											
										</h:panelGrid>
										
										<h:panelGrid columns="6" >
											<p:outputLabel value="#{msg.lbl_farm_code}:" for="farmcode" style="display:block;width:140px;"/>
											<p:inputText id="farmcode" value="#{facturaDataManager.tfaccabfactura.farmcode}" style="display:block;width:180px;" disabled="#{facturaDataManager.editable}" 
												required="true" onkeyup="bunsys.toUppercase(event, this)" />
											<p:message for="farmcode" display="icon"/>
											
											<p:outputLabel value="#{msg.lbl_master_awb}:" for="masterawb" style="display:block;width:140px;"/>
											<p:inputMask id="masterawb" value="#{facturaDataManager.tfaccabfactura.masterawb}" disabled="#{facturaDataManager.editable}"
											 style="display:block;width:180px;" required="true" mask="999-9999-9999" />											
											<p:message for="masterawb" display="icon"/>
										</h:panelGrid>
										
										<h:panelGrid columns="6" >
											<p:outputLabel value="#{msg.lbl_house_awb}:" for="houseawb" style="display:block;width:140px;"/>
											<p:inputText id="houseawb" value="#{facturaDataManager.tfaccabfactura.houseawb}" disabled="#{facturaDataManager.editable}" 
												style="display:block;width:180px;" required="true" onkeyup="bunsys.toUppercase(event, this)" />
											<p:message for="houseawb" display="icon"/>
										</h:panelGrid>
										
										<h:panelGrid columns="6" >
											<p:outputLabel value="#{msg.lbl_carguera}:" for="carguera" style="display:block;width:140px;"/>
											<p:selectOneMenu id="carguera" value="#{facturaDataManager.tfaccabfactura.carguera}" disabled="#{facturaDataManager.editable}"
												  var="p" style="width:180px" panelStyle="width:180px" >						
												<f:selectItem itemLabel="Seleccione" itemValue="" />
												<f:selectItems value="#{facturaDataManager.catalogocarguera}" var="item" itemValue="#{item.pk.codigocatalogo}" itemLabel="#{item.descripcion}" />
											</p:selectOneMenu>
											<p:message for="carguera" display="icon"/>
											
											<p:outputLabel value="#{msg.lbl_aerolinea}:" for="txtaerolinea" style="display:block;width:140px;"/>
											<p:selectOneMenu id="txtaerolinea" value="#{facturaDataManager.tfaccabfactura.airline}" disabled="#{facturaDataManager.editable}"
												  var="p" style="width:180px" panelStyle="width:180px" required="true" >						
												<f:selectItem itemLabel="Seleccione" itemValue="" />
												<f:selectItems value="#{facturaDataManager.aerolineasCatalogo}" var="item" itemValue="#{item.pk.codigocatalogo}" itemLabel="#{item.descripcion}" />
											</p:selectOneMenu>	
											<p:message for="txtaerolinea" display="icon"/>
											
										</h:panelGrid>
										
										<h:panelGrid columns="6" >
											<p:outputLabel value="#{msg.lbl_fob}:" for="fob" style="display:block;width:140px;"/>
											<p:selectOneMenu id="fob" value="#{facturaDataManager.tfaccabfactura.fob}" disabled="#{facturaDataManager.editable}"
												  var="p" style="width:180px" panelStyle="width:180px" required="true">						
												<f:selectItem itemLabel="Seleccione" itemValue="" />
												<f:selectItems value="#{facturaDataManager.catalogofob}" var="item" itemValue="#{item.pk.codigocatalogo}" itemLabel="#{item.descripcion}" />
											</p:selectOneMenu>
											<p:message for="fob" display="icon"/>
											
											<p:outputLabel value="#{msg.lbl_aeropuerto}:" for="dae" style="display:block;width:140px;" />
											<p:inputText id="dae" value="#{facturaDataManager.tfaccabfactura.dae}" style="display:block;width:180px;" disabled="#{facturaDataManager.editable}"
												 required="true" onkeyup="bunsys.toUppercase(event, this)" />
											<p:message for="dae" display="icon"/>
											
										</h:panelGrid>
										<h:panelGrid columns="6" >
											<p:outputLabel value="#{msg.lbl_consignee}:" for="consigne" style="display:block;width:140px;"/>
											<p:inputText id="consigne" value="#{facturaDataManager.tfaccabfactura.consignee}" disabled="#{facturaDataManager.editable}" 
												style="display:block;width:180px;" required="false" onkeyup="bunsys.toUppercase(event, this)" />
											<p:message for="consigne" display="icon"/>
											
											<p:outputLabel value="#{msg.lbl_fixed_price}:" for="fixedprice" style="display:block;width:142px;"/>
											<p:inputText id="fixedprice" value="#{facturaDataManager.tfaccabfactura.fixedprice}" disabled="#{facturaDataManager.editable}"
												 style="display:block;width:180px;" required="false" onkeyup="bunsys.toUppercase(event, this)" />
											<p:message for="fixedprice" display="icon"/>	
										</h:panelGrid>
										
										<h:panelGrid columns="6">
											<p:outputLabel for="fecha" value="#{msg.lbl_fecha_despacho}:" style="display:block;width:140px;"/>
										    <p:calendar id="fecha" value="#{facturaDataManager.tfaccabfactura.fechafactura}" disabled="#{facturaDataManager.editable}"
										    	  style="display:block;width:180px;" required="true" pattern="#{msg['pattern_date']}" mask="true"/>
										    <p:message for="fecha" display="icon"/>
										    
										    <p:outputLabel for="fechaVuelo" value="#{msg.lbl_fecha_vuelo}:" style="display:block;width:140px;"/>
										    <p:calendar id="fechaVuelo" value="#{facturaDataManager.tfaccabfactura.fechaembarque}" disabled="#{facturaDataManager.editable}"
										    	  style="display:block;width:180px;" required="true" pattern="#{msg['pattern_date']}" mask="true"/>
										    <p:message for="fechaVuelo" display="icon"/>
										</h:panelGrid>
										
										<h:panelGrid columns="15" >
										    <p:outputLabel value="#{msg.lbl_country_code}:" for="countrycode" style="display:block;width:140px;"/>
											<p:inputText id="countrycode" value="#{facturaDataManager.tfaccabfactura.countrycode}" disabled="#{facturaDataManager.editable}"
												 style="display:block;width:50px;" required="true" onkeyup="bunsys.toUppercase(event, this)" />
											<p:message for="countrycode" display="icon"/>
											
											<p:outputLabel value="#{msg.lbl_area}:" for="area" style="display:block;width:60px;"/>
											<p:inputText id="area" value="#{facturaDataManager.tfaccabfactura.area}" disabled="#{facturaDataManager.editable}"
												 style="display:block;width:80px;" required="true" onkeyup="bunsys.toUppercase(event, this)" />
											<p:message for="area" display="icon"/>
											
										</h:panelGrid>
									</h:panelGroup>
							</p:panelGrid>
							<p:panelGrid columns="1" style="width: 100%;">
								<f:facet name="header">
									<h:outputText value="#{msg['lbl_datos_cliente']}" />
								</f:facet>
								<h:panelGrid columns="3" id="pnlcliente" >
									<p:outputLabel value="#{msg.lbl_codigo_cliente}:" for="txtcodcliente" style="display:block;width:140px;"/>
									<p:inputText id="txtcodcliente" value="#{facturaDataManager.tfaccliente.tsyspersona.pk.codigopersona}" style="display:block;width:180px;" disabled="true"/>
									<p:commandButton icon="ui-icon-extlink" oncomplete="PF('dlgClienteBusqueda').show();" disabled="#{facturaDataManager.editable}" />
								    <p:outputLabel value="#{msg.lbl_nombre_persona}:" for="consignename" style="display:block;width:100px;"/>
									<p:inputText id="consignename" value="#{facturaDataManager.tfaccliente.tsyspersona.nombres}" style="display:block;width:440px;" disabled="true"/>
								</h:panelGrid>
							</p:panelGrid>
						</h:panelGroup>
					
			</p:fieldset>
			<p:fieldset id="pnlDetallefactura" legend="#{msg['lbl_detalle']}">
				<p:panelGrid columns="1" style="width: 100%;">
					<f:facet name="header">
						<h:outputText value="#{msg['lbl_datos_articulo']}" rendered="#{!facturaDataManager.editable}"/>
					</f:facet>
					<h:panelGroup layout="block" rendered="#{!facturaDataManager.editable}">
							<h:panelGrid id="pnldetalleproducto" columns="3" >
								<p:outputLabel value="#{msg.lbl_nombre}:" for="nomproducto"  style="display:block;width:100px;"/>
								<p:inputText id="nomproducto" value="#{facturaDataManager.tinvproducto.nombre}"  style="display:block;width:200px;" disabled="true"/>
								<p:commandButton icon="ui-icon-extlink" oncomplete="PF('dlgArticuloSel').show();" />
							    <p:outputLabel value="#{msg.lbl_precio}:" for="preproducto"  style="display:block;width:100px;"/>
								<p:inputText id="preproducto" value="#{facturaDataManager.tinvproducto.preciounitario}" style="display:block;width:180px;" disabled="true"/>
							</h:panelGrid>
							<h:panelGrid columns="6" id="pnldetalle" >
								<p:commandButton id="btnagregar" value="#{msg['btn_anadir']}" icon="ui-icon-plusthick"  process="@this pnldetalle"
									 action="#{facturaController.agregarProducto()}" update="pnldetalle, detalleFactura, pnldetalleproducto totales" />
							</h:panelGrid>
					</h:panelGroup>	
					<p:dataTable id="detalleFactura" value="#{facturaDataManager.tfaccabfactura.tfacdetfacturas}" var="item" scrollable="true"
							 		style="width:auto;font: bold 100% monospace; " scrollWidth="900" scrollRows="5" >
								<p:column headerText="#{msg.lbl_pices_type}" style="width:100px" >
									<p:selectOneMenu id="catpicestype" value="#{item.unidadventa}"  var="p" style="width:100px" panelStyle="width:100px" disabled="#{facturaDataManager.editable}">						
										<p:ajax event="change"  listener="#{facturaController.cambioPicesType(item)}" 
											process="@this catpicestype" update="picestype eqfullboxes stemsbunch totalbunch totalstems priceunit totalprice :frm:total :frm:sinimpuestos :frm:subtotal12  :frm:noiva :frm:exiva :frm:descuento :frm:iva12 :frm:pnlformapago"/>
										<f:selectItems value="#{facturaDataManager.catalogoPicesType}" 
											var="itemcat" itemValue="#{itemcat.pk.codigocatalogo}" itemLabel="#{itemcat.descripcion}"/>
									</p:selectOneMenu>	
								</p:column>
								<p:column headerText="#{msg.lbl_total_pice}" style="width:100px">
									<pe:inputNumber id="picestype" value="#{item.cantidad}"  decimalPlaces="2" decimalSeparator="." thousandSeparator="" 
										styleClass="b-input50" style="text-align:right" disabled="#{facturaDataManager.editable}">
										<p:ajax event="change"  listener="#{facturaController.cambioCantidad(item)}" 
											process="@this picestype" update="picestype eqfullboxes stemsbunch totalbunch totalstems priceunit totalprice :frm:total :frm:sinimpuestos :frm:subtotal12  :frm:noiva :frm:exiva :frm:descuento :frm:iva12 :frm:pnlformapago"/>
									</pe:inputNumber>
								</p:column>
								<p:column headerText="#{msg.lbl_eq_full_boxes}" style="width:100px">
									<pe:inputNumber  id="eqfullboxes" value="#{item.eqfullboxes}" decimalPlaces="2" decimalSeparator="." thousandSeparator="" 
										styleClass="b-input50" style="text-align:right" disabled="true">
										<p:ajax event="change"  listener="#{facturaController.cambioeqfullboxes(item)}" 
											process="@this eqfullboxes" update="picestype eqfullboxes stemsbunch totalbunch totalstems priceunit totalprice :frm:total :frm:sinimpuestos :frm:subtotal12  :frm:noiva :frm:exiva :frm:descuento :frm:iva12 :frm:pnlformapago"/>
									</pe:inputNumber>
								</p:column>
								<p:column headerText="#{msg.lbl_product_description}" style="width:100px">
									<p:outputLabel value="#{item.tinvproducto.nombre}"/>
								</p:column>
								<p:column headerText="#{msg.lbl_atpa}" style="width:100px">
									<p:outputLabel value="#{item.atpa}"/>
								</p:column>
								<p:column headerText="#{msg.lbl_andina}" style="width:100px">
									<p:outputLabel value="#{item.nandina}"/>
								</p:column>
								<p:column headerText="#{msg.lbl_stems_bunch}" style="width:100px">
									<pe:inputNumber  id="stemsbunch" value="#{item.stemsbunch}" decimalPlaces="2" decimalSeparator="." thousandSeparator="" disabled="#{facturaDataManager.editable}"
										 styleClass="b-input50" style="text-align:right">
										<p:ajax event="change"  listener="#{facturaController.cambioStemsBunch(item)}" 
											process="@this stemsbunch" update="picestype eqfullboxes stemsbunch totalbunch totalstems priceunit totalprice :frm:total :frm:sinimpuestos :frm:subtotal12  :frm:noiva :frm:exiva :frm:descuento :frm:iva12 :frm:pnlformapago"/>
									</pe:inputNumber>
								</p:column>
								<p:column headerText="#{msg.lbl_boxs}" style="width:100px">
									<pe:inputNumber  id="cajas" value="#{item.cajas}"  decimalPlaces="2" decimalSeparator="." thousandSeparator=""  maxValue="9999"
										styleClass="b-input50" style="text-align:right" disabled="#{facturaDataManager.editable}">
										<p:ajax event="change"  listener="#{facturaController.cambiototalBunch(item)}" 
											process="@this" update="picestype eqfullboxes stemsbunch totalbunch totalstems priceunit totalprice :frm:total :frm:sinimpuestos :frm:subtotal12  :frm:noiva :frm:exiva :frm:descuento :frm:iva12 :frm:pnlformapago"/>
									</pe:inputNumber>
								</p:column>
								<p:column headerText="#{msg.lbl_total_bunch}" style="width:100px">
									<pe:inputNumber  id="totalbunch" value="#{item.totalbunch}"  decimalPlaces="2" decimalSeparator="." thousandSeparator="" 
										styleClass="b-input100" style="text-align:right" disabled="true">
									</pe:inputNumber>
								</p:column>
								<p:column headerText="#{msg.lbl_total_stems}" style="width:100px">
									<pe:inputNumber   id="totalstems" value="#{item.totalstems}"   decimalPlaces="2" decimalSeparator="." thousandSeparator="" 
										styleClass="b-input100" style="text-align:right" disabled="true">
										<p:ajax event="change"  listener="#{facturaController.cambiototalSteams(item)}" 
											process="@this totalstems" update="picestype eqfullboxes stemsbunch totalbunch totalstems priceunit totalprice :frm:total :frm:sinimpuestos :frm:subtotal12  :frm:noiva :frm:exiva :frm:descuento :frm:iva12 :frm:pnlformapago"/>
									</pe:inputNumber>
								</p:column>
								<p:column headerText="#{msg.lbl_unit_price}" style="width:100px">
									<pe:inputNumber  id="priceunit" value="#{item.preciounitario}"   decimalPlaces="2" decimalSeparator="." thousandSeparator="" 
										styleClass="b-input50" style="text-align:right" disabled="#{facturaDataManager.editable}">
										<p:ajax event="change"  listener="#{facturaController.cambiounitprice(item)}" 
											process="@this priceunit" update="picestype eqfullboxes stemsbunch totalbunch totalstems priceunit totalprice :frm:total :frm:sinimpuestos :frm:subtotal12  :frm:noiva :frm:exiva :frm:descuento :frm:iva12 :frm:pnlformapago"/>
									</pe:inputNumber>
								</p:column>
								<p:column headerText="#{msg.lbl_total_price}" style="width:100px">
									<pe:inputNumber   id="totalprice" value="#{item.total}"   decimalPlaces="2" decimalSeparator="." thousandSeparator="" disabled="true" 
										styleClass="b-input100" style="text-align:right" >
										<p:ajax event="change"  listener="#{facturaController.cambiototal(item)}" 
											process="@this totalprice" update="picestype eqfullboxes stemsbunch totalbunch totalstems priceunit totalprice :frm:total :frm:sinimpuestos :frm:subtotal12  :frm:noiva :frm:exiva :frm:descuento :frm:iva12 :frm:pnlformapago"/>
									</pe:inputNumber>
								</p:column>
								<p:column style="width:30px">
									<p:commandButton id="btneliminar" icon="ui-icon-close" disabled="#{facturaDataManager.editable}"
										action="#{facturaController.eliminarArticulo(item)}" process="@this detalleFactura" update="detalleFactura :frm:totales :frm:sinimpuestos :frm:subtotal12  :frm:noiva :frm:exiva :frm:descuento :frm:iva12 :frm:pnlformapago" />
								</p:column>
							</p:dataTable>
					</p:panelGrid>
			</p:fieldset>
			
			<p:fieldset legend="#{msg['lbl_totales']}" id="totales">
				<h:panelGrid columns="6">
					<p:outputLabel value="#{msg['lbl_porcentaje_desc']}:" style="display:block;width: 150px;" for="pordescuento"/>
					<p:inputText id="pordescuento" value="#{facturaDataManager.tfaccliente.porcentajedescuento}" disabled="#{facturaDataManager.editable}">
						<p:ajax event="blur" listener="#{facturaController.calculos()}" process="@this pordescuento" update=":frm:sinimpuestos :frm:subtotal12  :frm:noiva :frm:exiva :frm:descuento :frm:iva12 total :frm:pnlformapago"></p:ajax>
					</p:inputText>
				</h:panelGrid>
				<h:panelGrid columns="6">
					<p:outputLabel value="#{msg['lbl_subtotal_sin_impuestos']}:" style="display:block;width: 180px;"/>
					<h:outputText id="sinimpuestos" value="#{facturaDataManager.tfaccabfactura.subtotalneto}" style="display:block;width: 100px;">
						<f:convertNumber pattern="#{msg.pattern_decimal}" />
					</h:outputText>
					
					<p:outputLabel value="#{msg['lbl_subtotal12']}:" style="display:block;width: 180px;"/>
					<h:outputText  id="subtotal12" value="#{facturaDataManager.tfaccabfactura.subtotaliva}" style="display:block;width: 100px;">
						<f:convertNumber pattern="#{msg.pattern_decimal}" />
					</h:outputText>
					
					<p:outputLabel value="#{msg['lbl_subtotal_noiva']}:"/>
					<h:outputText id="noiva" value="#{facturaDataManager.tfaccabfactura.subtotalnoiva}" >
						<f:convertNumber pattern="#{msg.pattern_decimal}" />
					</h:outputText>
					
					<p:outputLabel  value="#{msg['lbl_subtotal_exiva']}:" />
					<h:outputText id="exiva" value="#{facturaDataManager.tfaccabfactura.subtotalexcentoiva}" >
						<f:convertNumber pattern="#{msg.pattern_decimal}" />
					</h:outputText>
					
					<p:outputLabel value="#{msg['lbl_total_descuento']}:"/>
					<h:outputText id="descuento" value="#{facturaDataManager.tfaccabfactura.totaldescuento}" >
						<f:convertNumber pattern="#{msg.pattern_decimal}" />
					</h:outputText>
					
					<p:outputLabel value="#{msg['lbl_iva12']}:" />
					<h:outputText id="iva12" value="#{facturaDataManager.tfaccabfactura.iva}" >
						<f:convertNumber pattern="#{msg.pattern_decimal}" />
					</h:outputText>
					
					<p:outputLabel value="#{msg['lbl_total_factura']}:"/>
					<h:outputText id="total" value="#{facturaDataManager.tfaccabfactura.total}" >
						<f:convertNumber pattern="#{msg.pattern_decimal}" />
					</h:outputText>	
				</h:panelGrid>
			</p:fieldset>
			
			
			<p:fieldset  header="#{msg['lbl_forma_pago_m']}">
				<h:panelGroup id="pnlformapago" layout="block">
					<h:panelGrid columns="4" cellpadding="5">
						<h:outputText value="#{msg.lbl_efectivo} " />
			            <p:selectBooleanCheckbox value="#{facturaDataManager.formaPago1}" disabled="#{facturaDataManager.editable}">
				            <p:ajax update="pnlformapago" listener="#{facturaController.formaPagoEfectivo()}" />
				        </p:selectBooleanCheckbox>
				        <h:outputText value="#{msg.lbl_credito} " />
				        <p:selectBooleanCheckbox value="#{facturaDataManager.formaPago2}" disabled="#{facturaDataManager.editable}">
				            <p:ajax update="pnlformapago" listener="#{facturaController.formaPagoCheque()}" />
				        </p:selectBooleanCheckbox>
			        </h:panelGrid>
			        <h:panelGrid columns="4" id="efectivo" rendered="#{facturaDataManager.formaPago1}">
			        	<p:outputLabel value="#{msg.lbl_efectivo}:" for="valorefectivo" style="padding-left:4px;display:block;width:100px;"/>
			        	<pe:inputNumber id="valorefectivo" value="#{facturaDataManager.efectivo}" decimalPlaces="2" decimalSeparator="." thousandSeparator="," disabled="#{facturaDataManager.editable}" />
			        	<p:outputLabel/>
			        	<p:outputLabel/>
			        	
						<p:outputLabel value="#{msg.lbl_cheque}:" for="cheque" style="padding-left:4px;display:block;width:100px;"/>
						<pe:inputNumber id="cheque" value="#{facturaDataManager.cheque}" decimalPlaces="2" decimalSeparator="." thousandSeparator="," disabled="#{facturaDataManager.editable}"/>
						<p:outputLabel value="#{msg.lbl_institucion}:" for="institucioncheque" style="padding-left:4px;display:block;width:100px;"/>
						<p:selectOneMenu id="institucioncheque" value="#{facturaDataManager.institucionCheque}" disabled="#{facturaDataManager.editable}">
		  					<f:selectItem itemLabel="Seleccione" itemValue="#{null}"/>
		  					<f:selectItems value="#{facturaDataManager.institucion}" var="item" itemLabel="#{item.descripcion}" itemValue="#{item.pk.codigocatalogo}"/>
		  				</p:selectOneMenu>
		  				
						<p:outputLabel value="#{msg.lbl_transferencia}:" for="transferencia" style="padding-left:4px;display:block;width:100px;"/>
						<pe:inputNumber id="transferencia" value="#{facturaDataManager.transferencia}" decimalPlaces="2" decimalSeparator="." thousandSeparator="," disabled="#{facturaDataManager.editable}"/>
						<p:outputLabel value="#{msg.lbl_institucion}:" for="instituciontransfer" style="padding-left:4px;display:block;width:100px;"/>
						<p:selectOneMenu id="instituciontransfer" value="#{facturaDataManager.institucionTransferencia}" disabled="#{facturaDataManager.editable}">
		  					<f:selectItem itemLabel="Seleccione" itemValue="#{null}"/>
		  					<f:selectItems value="#{facturaDataManager.institucion}" var="item" itemLabel="#{item.descripcion}" itemValue="#{item.pk.codigocatalogo}"/>
		  				</p:selectOneMenu>
		  				
						<p:outputLabel value="#{msg.lbl_tarjeta_credito}:" for="tarjcredito" style="padding-left:4px;display:block;width:100px;"/>
						<pe:inputNumber id="tarjcredito" value="#{facturaDataManager.tarjetaCredito}" decimalPlaces="2" decimalSeparator="." thousandSeparator="," disabled="#{facturaDataManager.editable}"/>
						<p:outputLabel value="#{msg.lbl_institucion}:" for="instituciontarjcred" style="padding-left:4px;display:block;width:100px;"/>
						<p:selectOneMenu id="instituciontarjcred" value="#{facturaDataManager.institucionTarjetaCredito}" disabled="#{facturaDataManager.editable}">
		  					<f:selectItem itemLabel="Seleccione" itemValue="#{null}"/>
		  					<f:selectItems value="#{facturaDataManager.institucion}" var="item" itemLabel="#{item.descripcion}" itemValue="#{item.pk.codigocatalogo}"/>
		  				</p:selectOneMenu>
			        </h:panelGrid>
			        <h:panelGrid columns="2" id="pnlcredito" rendered="#{facturaDataManager.formaPago2}">
			        	<p:outputLabel value="#{msg.lbl_credito}" for="credito" style="padding-left:4px;display:block;width:100px;"/>
						<p:inputText id="credito" value="#{facturaDataManager.tfaccabfactura.total}" style="display:block;width:100px;" disabled="true"/>
						<p:outputLabel value="#{msg.lbl_numero_pago}" for="numpagos" style="padding-left:4px;display:block;width:100px;"/>
						<p:inputText  	id="numpagos"	value="#{facturaDataManager.numeropagos}" 	required="true" style="width:100px" disabled="#{facturaDataManager.editable}">						
							<pe:keyFilter regEx="/[\d\-]/" />
						</p:inputText>		
			        </h:panelGrid>
			    </h:panelGroup>
			</p:fieldset>
			
			
			
			<h:panelGrid columns="4">

				<p:commandButton id="btngrabarsinfirma" icon="ui-icon-disk" value="#{msg['btn_guardar_nofirma']}" action="#{facturaController.grabarSinFirma()}" 
					process="@this detalleFactura pnldatoscab :frm:pnlformapago pnlcredito" disabled="#{facturaDataManager.tfaccabfactura.estadosri=='FE'}"
					update="pnldetalle, detalleFactura :frm:pnlDatos :frm:pnlformapago pnlcredito" />
					
				<p:commandButton id="btngrabarfirmeniviar" icon="ui-icon-disk" value="#{msg['btn_guardar_firmar_enviar']}"  
					process="@this detalleFactura pnldatoscab :frm:pnlformapago pnlcredito" disabled="#{facturaDataManager.tfaccabfactura.estadosri=='FE'}" 
					update="pnldetalle, detalleFactura :frm:pnlDatos :frm:pnlformapago pnlcredito" 
					oncomplete="if (!args.validationFailed){ PF('dialogPassword').show();}" />
				
				<p:commandButton id="btnfirmarenviar" icon="ui-icon-disk" value="#{msg['btn_firmar_enviar']}"  
					process="@this detalleFactura pnldatoscab :frm:pnlformapago pnlcredito"  disabled="#{facturaDataManager.tfaccabfactura.estadosri=='FE'}" 
					update="pnldetalle, detalleFactura :frm:pnlDatos :frm:pnlformapago pnlcredito" 
					oncomplete="if (!args.validationFailed){ PF('dialogPassword').show();}"/>
						
				<p:commandButton id="btncancelar" icon="ui-icon-close" value="#{msg.btn_cancelar}" action="#{facturaController.cancelar()}" 
					process="@this detalleFactura :frm:pnlDatos" update="pnldetalle, detalleFactura, pnldatoscab, pnlDetallefactura" immediate="true"/>
			</h:panelGrid>
		</p:panel>
	</ui:define>
	
	<ui:define name="dialogArea">
		<p:dialog widgetVar="dlgClienteBusqueda" appendTo="@(body)" modal="true" resizable="false" closeOnEscape="true" >
		<h:form id="frmClis">
			<p:panel header="#{msg.lbl_clientes}" style="width:900px !important">
				  	<p:fieldset legend="#{msg['lbl_busqueda']}">
				  		<h:panelGroup layout="block" id="pnlBusquedacliente">
				  			<h:panelGrid columns="3">
				  				<p:outputLabel value="#{msg['lbl_marcacion']}:" for="txtNombre"/>
				  				<p:inputText id="txtNombre" value="#{clienteDatamanager.clienteserch.tsyspersona.nombres}"/>
				  				<p:message for="txtNombre" display="icon"/>
				  				<p:outputLabel value="#{msg['lbl_cliente']}:" for="txtApellidos"/>
				  				<p:inputText id="txtApellidos" value="#{clienteDatamanager.clienteserch.tsyspersona.apellidos}"/>
				  				<p:message for="txtApellidos" display="icon"/>
				  				<p:outputLabel value="#{msg['lbl_identificacion']}:" for="txtIdentificacion"/>
				  				<p:inputText id="txtIdentificacion" value="#{clienteDatamanager.clienteserch.tsyspersona.identificacion}"/>
				  				<p:message for="txtIdentificacion" display="icon"/>
				  			</h:panelGrid>
				  		</h:panelGroup>
				  		<h:panelGroup layout="block" style="float:left">
				  			<p:commandButton icon="ui-icon-search" value="#{msg['btn_buscar']}" action="#{clienteController.buscar()}" update="pnlDataArticulos" process="@this :frmClis:pnlBusquedacliente"/>
				  			<p:commandButton icon="ui-icon-plusthick" value="#{msg['btn_crear']}" oncomplete="PF('dlgCliente').show()" 
				  				action="#{clienteController.crearArticulo()}" update=":frmCreacionArticulos:pnlArticulo"/>
				  		</h:panelGroup>
				  	</p:fieldset>
				  	<p:fieldset legend="#{msg['lbl_listado_clientes']}">
				  		<h:panelGroup layout="block" id="pnlDataArticulos">
				  			<p:dataTable value="#{clienteDatamanager.clientesCol}" var="item" id="tblaDatos">
				  				<p:column headerText="#{msg['lbl_codigo_principal']}">
				  					<h:outputText value="#{item.pk.codigocliente}" />
				  				</p:column>
				  				<p:column headerText="#{msg['lbl_marcacion']} ">
				  					<h:outputText value="#{item.tsyspersona.nombres}" />
				  				</p:column>
				  				<p:column headerText="#{msg['lbl_cliente']}">
				  					<h:outputText value="#{item.tsyspersona.apellidos}" />
				  				</p:column>
				  				<p:column headerText="#{msg['lbl_tipo_id']}">
				  					<h:outputText value="#{item.tsyspersona.tadmtipopersona.descripcion}" />
				  				</p:column>
				  				<p:column headerText="#{msg['lbl_identificacion']}">
				  					<h:outputText value="#{item.tsyspersona.identificacion}" />
				  				</p:column>
				  				<p:column headerText="#{msg['lbl_estado']}">
				  					<h:outputText value="#{item.tsyspersona.tadmestado.descripcion}" />
				  				</p:column>
				  				<p:column styleClass="bun-action" style="text-align:center">
				  					<p:commandButton icon="ui-icon-pencil" title="#{msg['btn_actualizar']}" oncomplete="PF('dlgCliente').show();" update=":frmCreacionArticulos:pnlArticulo" process="@this" immediate="true">
				  						<f:setPropertyActionListener target="#{clienteDatamanager.clienteComponente.tfaccliente}" value="#{item}"/>
				  					</p:commandButton>
				  				</p:column>
				  				<p:column styleClass="bun-action" style="text-align:center">
				  					<p:commandButton icon="ui-icon-trash" title="#{msg['btn_eliminar']}" action="#{clienteController.eliminar(item.tsyspersona.pk.codigopersona)}" update=":frmClis:pnlDataArticulos" process="@this"/>
				  				</p:column>
				  				<p:column styleClass="bun-action" style="text-align:center">
				  					<p:commandButton icon="ui-icon-circle-check" title="#{msg['btn_seleccionar']}" oncomplete="PF('dlgClienteBusqueda').hide();" update=":frm:pnlcliente" process="@this" immediate="true">
				  						<f:setPropertyActionListener target="#{facturaDataManager.tfaccliente}" value="#{item}"/>
				  					</p:commandButton>
				  				</p:column>
				  			</p:dataTable>
				  		</h:panelGroup>
				  	</p:fieldset>
		  </p:panel>
		</h:form>	
		</p:dialog>
	  	<p:dialog widgetVar="dlgCliente" appendTo="@(body)" modal="true" resizable="false" closeOnEscape="true">
	  		<f:facet name="header">
	  			<h:outputText value="#{msg['lbl_clientes']}" />
	  		</f:facet>
			<h:form id="frmCreacionArticulos">
				<b:clienteComponent id="pnlArticulo" controller="#{clienteDatamanager.clienteComponente}" processSave="@this" updateSave=":frmClis:pnlDataArticulos" oncompleteSave="PF('dlgCliente').hide();" oncompleteCancel="PF('dlgCliente').hide();"/>
			</h:form>	  		
	  	</p:dialog>
	  	
	  	<!-- articulo -->
	  	<p:dialog widgetVar="dlgArticuloSel" appendTo="@(body)" modal="true" resizable="false" closeOnEscape="true">
	  	<h:form id="frmBusAr">
			  	<p:panel header="#{msg['lbl_articulos']}" style="width:900px !important">
				  	<p:fieldset legend="#{msg['lbl_busqueda']}">
				  		<h:panelGroup layout="block">
				  			<h:panelGrid columns="3" id="pnlBusqueda">
				  				<p:outputLabel value="#{msg['lbl_codigo_principal']}:" for="txtCodigoPrincipal"/>
				  				<p:inputText id="txtCodigoPrincipal" value="#{articuloDatamanager.articuloSearch.pk.codigoproductos}"/>
				  				<p:message for="txtCodigoPrincipal" display="icon"/>
				  				
				  				<p:outputLabel value="#{msg['lbl_codigo_auxiliar']}:" for="txtCodigoAuxiliar"/>
				  				<p:inputText id="txtCodigoAuxiliar" value="#{articuloDatamanager.articuloSearch.codigoauxiliar}"/>
				  				<p:message for="txtCodigoAuxiliar" display="icon"/>
				  				
				  				<p:outputLabel value="#{msg['lbl_nombre_producto']}:" for="txtNombreProducto"/>
				  				<p:inputText id="txtNombreProducto" value="#{articuloDatamanager.articuloSearch.nombre}"/>
				  				<p:message for="txtNombreProducto" display="icon"/>
				  				
				  				<p:outputLabel value="#{msg['lbl_color']}:" for="selColor"/>
				  				<p:selectOneMenu id="selColor" value="#{articuloDatamanager.articuloSearch.color}">
				  					<f:selectItem itemLabel="Seleccione" itemValue="#{null}"/>
				  					<f:selectItems value="#{articuloDatamanager.colorCatalogoColl}" var="color" itemLabel="#{color.descripcion}" itemValue="#{color.pk.codigocatalogo}"/>
				  				</p:selectOneMenu>
				  				<p:message for="selColor" display="icon"/>
				  				
				  				<p:outputLabel value="#{msg['lbl_estado']}:" for="selEstado"/>
				  				<p:selectOneMenu id="selEstado" value="#{articuloDatamanager.articuloSearch.estado}">
				  					<f:selectItem itemLabel="Seleccione" itemValue="#{null}"/>
				  					<f:selectItems value="#{articuloDatamanager.estadoCatalogoColl}" var="estado" itemLabel="#{estado.descripcion}" itemValue="#{estado.pk.codigocatalogo}" />
				  				</p:selectOneMenu>
				  				<p:message for="selEstado" display="icon"/>
				  			</h:panelGrid>
				  		</h:panelGroup>
				  		<h:panelGroup layout="block" style="float:left">
				  			<p:commandButton icon="ui-icon-search" value="#{msg['btn_buscar']}" action="#{articuloController.buscar()}" update="pnlDataArticulosSel" process="@this pnlBusqueda"/>
				  			<p:commandButton icon="ui-icon-plusthick" 	value="#{msg['btn_crear']}"	oncomplete="PF('dlgArticulo').show()" 	action="#{articuloController.crearArticulo()}" 
				  				update=":frmArticulos:pnlArticulo"/>
				  		</h:panelGroup>
				  	</p:fieldset>
				  	<p:fieldset legend="#{msg['lbl_listado_articulos']}">
				  		<h:panelGroup layout="block" id="pnlDataArticulosSel">
				  			<p:dataTable value="#{articuloDatamanager.productoColl}" var="articulo">
				  				<p:column headerText="#{msg['lbl_codigo_principal']}">
				  					<h:outputText value="#{articulo.pk.codigoproductos}" />
				  				</p:column>
				  				<p:column headerText="#{msg['lbl_codigo_auxiliar']}">
				  					<h:outputText value="#{articulo.codigoauxiliar}" />
				  				</p:column>
				  				<p:column headerText="#{msg['lbl_nombre_producto']}">
				  					<h:outputText value="#{articulo.nombre}" />
				  				</p:column>
				  				<p:column headerText="#{msg['lbl_tipo_producto']}">
				  					<h:outputText value="#{articulo.tadmtipoproducto.descripcion}" />
				  				</p:column>
				  				<p:column headerText="#{msg['lbl_precio']}">
				  					<h:outputText value="#{articulo.preciounitario}" />
				  				</p:column>
				  				<p:column headerText="#{msg['lbl_estado']}">
				  					<h:outputText value="#{articulo.tadmestado.descripcion}" />
				  				</p:column>
				  				<p:column styleClass="bun-action">
				  					<p:commandButton icon="ui-icon-pencil" title="#{msg['btn_actualizar']}" oncomplete="PF('dlgArticulo').show();" update=":frmArticulos:pnlArticulo" process="@this">
				  						<f:setPropertyActionListener target="#{articuloDatamanager.articuloComponente.articulo}" value="#{articulo}"/>
				  					</p:commandButton>
				  				</p:column>
				  				<p:column styleClass="bun-action">
				  					<p:commandButton icon="ui-icon-trash" title="#{msg['btn_eliminar']}" action="#{articuloController.eliminar(articulo.pk.codigoproductos)}" process="@this" update=":frmBusAr:pnlDataArticulosSel"/>
				  				</p:column>
				  				<p:column styleClass="bun-action" style="text-align:center">
				  					<p:commandButton icon="ui-icon-circle-check" title="#{msg['btn_seleccionar']}" oncomplete="PF('dlgArticuloSel').hide();"  process="@this" immediate="true" update=":frm:pnldetalleproducto">
				  						<f:setPropertyActionListener target="#{facturaDataManager.tinvproducto}" value="#{articulo}"/>
				  					</p:commandButton>
				  				</p:column>
				  			</p:dataTable>
				  		</h:panelGroup>
				  	</p:fieldset>
				  </p:panel>
		</h:form>
	  	</p:dialog>
	    <p:dialog widgetVar="dlgArticulo" appendTo="@(body)" modal="true" resizable="false" closeOnEscape="true">
	  		<f:facet name="header">
	  			<h:outputText value="#{msg['lbl_articulos']}" />
	  		</f:facet>
			<h:form id="frmArticulos">
				<b:articuloComponent id="pnlArticulo" controller="#{articuloDatamanager.articuloComponente}" oncompleteCancel="PF('dlgArticulo').hide();"
					processSave="@this" updateSave=":frmBusAr:pnlDataArticulosSel" oncompleteSave="PF('dlgArticulo').hide();"/>
			</h:form>	  		
	  	</p:dialog>
	  	
	  	<p:dialog widgetVar="dialogPassword" appendTo="@(body)" modal="true" resizable="false" closeOnEscape="true">
	  		<f:facet name="header">
	  			<h:outputText value="#{msg['lbl_password']}" />
	  		</f:facet>
			<h:form id="frmPassword">
				<b:passwordComponent id="pnlArticulo" password="#{facturaDataManager.password}" iddialog="PF('dialogPassword').hide();"
					controller="#{facturaController}" showgfe="true"/>
			</h:form>	  		
	  	</p:dialog>
	  	
	  	<p:dialog widgetVar="dialogGrabar" appendTo="@(body)" modal="true" resizable="false" closeOnEscape="true">
			<h:form id="frmGrabar">
				<p:outputLabel value="#{msg.msg_info_no_existe_coneccion}" />
				<h:panelGrid>
					<p:commandButton icon="ui-icon-disk" value="#{msg['btn_guardar_contingencia']}" action="#{facturaController.grabarContingencia()}" 
					process="@this" oncomplete="PF('dialogGrabar').hide();" />
				</h:panelGrid>
			</h:form>	  		
	  	</p:dialog>
	  </ui:define>
</ui:composition>
